# -*- coding:utf-8 -*-
#

f = open("teste.txt", "w")
s = "treta"
for k in range(10): f.write(s); f.write("\n")
f.close()
f = open("teste.txt", "r")
f.seek(5)

print f.tell()
x=f.read(10)

print x


print " "

c=0
for line in f:
    print "{0}: ".format(c), line
    c+=1
f.close()

with open("teste.txt", "r") as f:
    x = f.readline()
    if x == 'treta\n': print " voila"


# exmplo sout.py

import sys
import random

lista_aleatorios = [random.uniform(0,100) for k in range(10)]

for x in lista_aleatorios:
	string1=str(x) +'\n'
	sys.stdout.write(string1)

try:
    a=0/0
except:
    sys.stderr.write("\nERRO 0/0 it's a no no... \n")

#seria.py
import pickle
class Teste:
    def __init__(self,x):
        self.x=x
obj = Teste(49)
f= open("teste.dat", "w")
p=pickle.dump(obj,f)
f.close()
del obj
obj=pickle.load(open("teste.dat","r"))
print obj.x


    
#lercsv.py

import csv

with open('notas.csv','wb') as csvfile:
    escritor = csv.writer(csvfile)
    escritor.writerow(['Programacao 1',14])
    escritor.writerow(['Programacao 2',15])
    escritor.writerow(['Linguagens de Programacao',19])
    
